define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'channel/agentchannel/index',
                    table: 't_stat_daily_openinstall_channel',
                },
                commonSearch: true,
                searchFormVisible: true,
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: true,
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [
                        {
                            field: 'dt',
                            title: __('统计日期'),
                            formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY-MM-DD",
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                        },
                        {field: 'reg_total', title: __('总注册用户'),operate: false},
                        {field: 'reg_male', title: __('注册男用户'),operate: false},
                        {field: 'reg_female', title: __('注册女用户'),operate: false},
                        {field: 'active_total', title: __('活跃总用户'),operate: false},
                        // {field: 'recharge_num', title: __('充值用户'),operate: false},
                        // {field: 'recharge_rmb', title: __('充值金额（元）'),operate: false},
                        {field: 'new_recharge_num', title: __('新增充值用户'),operate: false},
                        {field: 'new_recharge_rmb', title: __('新增充值金额（元）'),operate: false},
                        {field: 'order_p', title: __('充值转化率(新增充值用户/注册男用户)'),operate: false},
                        {field: 'channel', title: __('渠道'),searchList:channel, formatter: Table.api.formatter.normal},
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});